/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.entities;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Tuan Long
 */
@Entity
@Table(name = "ContactMessage")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ContactMessage.findAll", query = "SELECT c FROM ContactMessage c"),
    @NamedQuery(name = "ContactMessage.findById", query = "SELECT c FROM ContactMessage c WHERE c.id = :id"),
    @NamedQuery(name = "ContactMessage.findByMessageContent", query = "SELECT c FROM ContactMessage c WHERE c.messageContent = :messageContent"),
    @NamedQuery(name = "ContactMessage.findByRecieved", query = "SELECT c FROM ContactMessage c WHERE c.recieved = :recieved")})
public class ContactMessage implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "Id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;
    @Size(max = 2147483647)
    @Column(name = "MessageContent")
    private String messageContent;
    @Column(name = "Recieved")
    private Boolean recieved;
    @JoinColumn(name = "Username", referencedColumnName = "Username")
    @ManyToOne(optional = false)
    private Employee username;

    public ContactMessage() {
    }

    public ContactMessage(String messageContent, Employee username)
    {
        this.messageContent = messageContent;
        this.username = username;
    }

    public ContactMessage(Integer id, String messageContent, Boolean recieved, Employee username)
    {
        this.id = id;
        this.messageContent = messageContent;
        this.recieved = recieved;
        this.username = username;
    }
    
    

    public ContactMessage(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getMessageContent() {
        return messageContent;
    }

    public void setMessageContent(String messageContent) {
        this.messageContent = messageContent;
    }

    public Boolean getRecieved() {
        return recieved;
    }

    public void setRecieved(Boolean recieved) {
        this.recieved = recieved;
    }

    public Employee getUsername() {
        return username;
    }

    public void setUsername(Employee username) {
        this.username = username;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ContactMessage)) {
            return false;
        }
        ContactMessage other = (ContactMessage) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.entities.ContactMessage[ id=" + id + " ]";
    }
    
}
